import java.awt.Point;
import java.awt.image.BufferedImage;

public class Detector {

    public Point detect(BufferedImage image) {
        
        int [] argbArray = new int[image.getWidth() * image.getHeight()];
        int [] xy = new int[2];
        
        image.getRGB(0, 0, image.getWidth(), image.getHeight(), argbArray, 0, image.getWidth());
        if(detect(argbArray, image.getWidth(), image.getHeight(), xy)) {
            return new Point(xy[0], xy[1]);
        } else {
            return null;
        }
        
    }
    
    private native boolean detect(int[] argbArray, int width, int height, int[] xy);
    
    static {
        try {
            System.loadLibrary("ColorDetectorLibrary");
        } catch (UnsatisfiedLinkError ule) {
            System.out.println("loadLibrary(ColorDetectorLibrary)," + ule.getMessage());
        }
    }
}
